package controller;

import com.alibaba.fastjson.JSON;
import model.dto.PatientDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.JsonbHttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.PatientService;

/**
 * @className: controller.PatientController
 * @author: Xia
 * @create: 2023-03-15 13:51
 */
@Controller
@RequestMapping("/api/patient")
public class PatientController {
    @Autowired
    private PatientService service;
    @RequestMapping("patientAdd")
    public String toPatient(){
        return "patientAdd";
    }

    @ResponseBody
    @RequestMapping("getPatientByIdCard")
    public String getPatientByIdCard(String idCard){
        PatientDto patientByIdCard = service.getPatientByIdCard(idCard);
        return JSON.toJSONString(patientByIdCard);
    }

    @ResponseBody
    @RequestMapping("getPatientByIdMedicare")
    public String getPatientByIdMedicare(String idMedicare){
        PatientDto patientByIdMedicare = service.getPatientByIdMedicare(idMedicare);
        return JSON.toJSONString(patientByIdMedicare);
    }
}
